//package com.kira.scaffoldmvc.ShutDownHook;
//
//import jakarta.annotation.PostConstruct;
//import jakarta.annotation.PreDestroy;
//import org.springframework.stereotype.Service;
//
//import java.sql.DriverManager;
//
//@Service
//public class DatabaseService {
//    private Connection connection;
//
//    @PostConstruct
//    public void init() {
//        // 初始化数据库连接
//        this.connection = DriverManager.getConnection(url, username, password);
//    }
//
//    //标记Bean销毁前需要执行的方法
//    @PreDestroy
//    public void cleanup() {
//        // 应用关闭时自动释放数据库连接
//        if (connection != null) {
//            connection.close();
//            log.info("Database connection closed");
//        }
//    }
//}